import { Repository , getRepository } from 'typeorm';
import { validate, ValidationError } from "class-validator";
import { Leagues } from '../entity/leagues';

export default class LeagueControl {
    public static async saveLeague(league: Leagues) {
        const leagueRepository: Repository<Leagues> = getRepository( Leagues );
        const errors: ValidationError[] = await validate(league);
        if(errors.length > 0) console.log(errors);
        else await leagueRepository.save(league);
    }
}